﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace ShowroomMobile
{
    public partial class EditProfile : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (File.Exists(Server.MapPath("StaticPages/about.txt")))
                {
                    string content = File.ReadAllText(Server.MapPath("StaticPages/about.txt"));
                    ftbDescription.Text = content;
                }
                ((AdminSite)Page.Master).SetTitlePage("Edit Profile");
            }
        }

        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            File.WriteAllText(Server.MapPath("StaticPages/about.txt"), ftbDescription.Text);
            //File Write in Mobile Page
            string sMobionPath = Server.MapPath(Utilities.GetKeySetting("StaticPagesMobion"));
            DirectoryInfo dInfo = new DirectoryInfo(sMobionPath);
            if (!dInfo.Exists)
            {
                dInfo.Create();
            }
            File.WriteAllText(Path.Combine(sMobionPath, "about.txt"), ftbDescription.Text);
            ScriptManager.RegisterStartupScript(this, typeof(Page), Guid.NewGuid().ToString(), String.Format("showNotification('Star Case', 'Save successfully!', 8000);", 1), true);
        }
    }
}